package crowMessenger;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.jivesoftware.smack.RosterEntry;
import org.jivesoftware.smack.XMPPConnection;

public class Buddy extends JPanel{
	private static final long serialVersionUID = -2657872781465565747L;
	private RosterEntry rosterEntry;
	private String nickName;
	private String username;
	private int status;//0=available, 1=busy, 2=away, 3=invisible, 4=disconnected
	private String precense;
	private Color color;
	private ArrayList<Account> acc = new ArrayList<Account>(); //maybe a buddy belongs two or more accounts
	private ArrayList<XMPPConnection> connection = new ArrayList<XMPPConnection>(); //all connections that the buddy is associated with
	
	/* Constructor */
	public Buddy(RosterEntry rosterEntry, Color color, Account acc, XMPPConnection connection){
		setLayout(new BorderLayout());
		this.connection.add(connection);
		this.rosterEntry = rosterEntry;
		this.nickName = this.rosterEntry.getName();
		this.username = this.rosterEntry.getUser();
		this.status = 0;   						// must be defined properly
		this.precense = "";						// must be defined properly
		this.color = color;
		this.acc.add(acc); //the account which is given in constructor would be the first and default account
		createPanel();
	}
	
	/*private method to set attributes of the panel*/
	private void createPanel(){
		setBorder(BorderFactory.createLineBorder(Color.black, 1, true));
		setBackground(this.color);
		add(new JLabel(this.username));
	}
	
	protected String getNickname(){
		return this.nickName;
	}
	protected String getUsername(){
		return this.username;
	}
	protected XMPPConnection getConnection(){
		return connection.get(0); // for now returns the default connection
	} 
}
